package day05;
import java.util.Scanner;
import java.util.Arrays;
public class Day05HomeWork02 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        //===========================第一题========================
        int a_1,b_1;
        int answer;
        int scare=0;
        for(int i=0;i<10;i++){
            a_1=(int)(Math.random()*10);
            b_1=(int)(Math.random()*10);
            System.out.println(a_1+"+"+b_1+"=");
            int num=a_1+b_1;
            answer=scan.nextInt();
            if(answer==num){
                System.out.println("正确");
                scare+=10;
            }else {
                System.out.println("错误");
            }
        }
        System.out.println("最终得分为："+scare);
        //===========================第二题========================

        for (int i=1;i<10;i++){
            System.out.println();
            int a;
            for (a=1;a<=i;a++){
                System.out.print(a+"*"+i+"="+(a*i)+"\t");
            }
        }
        //===========================第三题========================
        //声明、初始化
        int[] arr_1=new int[4];
        int[] arr_2={1,3,6};
        int[] arr_3=new  int[]{4,5,7,8};
        int[] arr_4;
        arr_4=new int[]{2,5,7};
        //访问
        int[] arr_f={1,8,0,54,23};
        System.out.println("元素为："+ arr_f.length+"个");
        int a=arr_f[2];
        System.out.println(a);
        System.out.println(arr_f[2]);
        //遍历
        int[] arr_b;
        arr_b=new int[]{2,5,8,434,11,56,78};
        for(int i=0;i<arr_b.length;i++){
            System.out.println(arr_b[i]);
        }
        //===========================第四题========================
        int []A=new int[10];
        int max;
        for (int i=0;i<A.length;i++){
            A[i]=(int)(Math.random()*1000);
            System.out.println(A[i]);
        }
        max=A[0];
        for (int i=1;i<A.length;i++){

            if(max<A[i]){
                max=A[i];
            }
        }
        System.out.println("最大值"+max);
        //===========================第五题========================
        int[] arr=new int[10];
        for (int i=0;i<arr.length;i++){
            arr[i]=(int)(Math.random()*100);
            System.out.println(arr[i]);
        }
        Arrays.sort(arr);
        for (int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }
    }
}

